package gui.std;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import util.Constants;
import app.User;

@SuppressWarnings("serial")
public class GUserInfo extends JPanel {
	
	public GUserInfo(User u) {
		user = u;
		initialize();
	}
	
	private void initialize() {
		setLayout(new BorderLayout(5, 5));
		up = new JPanel(new BorderLayout());
		info = new JPanel(new GridLayout(0, 2));
		icon = new JButton("", new ImageIcon(user.getPathImage().replace("min", "max")));
		icon.setFocusable(false);
		icon.setBackground(Color.LIGHT_GRAY);
		
		nick = new JLabel(user.getNick(), JLabel.CENTER);
		nick.setFont(Constants.DEFAULT_MAX_FONT);
		
		up.add(nick, JLabel.CENTER);
		up.add(icon, BorderLayout.EAST);
		
		addInfo("Id");
		addInfo(""+user.getId());
		addInfo("Ip");
		addInfo(""+user.getIp());
		
		add(up, BorderLayout.NORTH);
		add(info);
	}
	
	private void addInfo(String i) {
		JLabel label = new JLabel(i, JLabel.LEFT);
		label.setFont(Constants.DEFAULT_FONT);
		label.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
		info.add(label);
	}
	
	private User user;
	private JButton icon;
	private JLabel nick;
	private JPanel up;
	private JPanel info;
}
